function oil = osl_load_oil(oildir)

% load OIL structure with the file name fname

if nargin==0
    [~, oildir]=uigetfile({'*.mat', 'MAT-files (*.mat)';'*.*', 'All Files'},'Select the OIL file');
end

oildir = strrep(oildir,'/oil.mat','');

tmp=load([oildir '/oil.mat']);
oil=tmp.oil;
oil.fname=oildir;

oil.source_recon.dirname = [oil.fname(1:strfind(oil.fname, '.oil')-1) '.oil'];

